package com.zxn.loadingdemo;

import android.graphics.Color;
import android.os.Bundle;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

import com.lemon.prompt.LoadingBox;
import com.lemon.prompt.LoadingConfig;
import com.lemon.prompt.OnDialogDismissListener;
import com.lemon.prompt.UploadLoadingBox;


public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private static final String text01 = "从前有坐山,山上有坐庙,庙里有个老和尚在讲故事,讲的什么啊,从前有座山,山里有座庙,庙里有个盆,盆里有个锅,锅里有个碗,碗里有个匙,匙里有个花生仁,我吃了,你谗了,我的故事讲完了.";


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //UIUtils.init(this);
        findViewById(R.id.btn03).setOnClickListener(this);
        int[] idArr = {R.id.btn_01, R.id.btn02, R.id.btn03, R.id.btn04, R.id.btn06};
        for (int i = 0; i < idArr.length; i++) {
            findViewById(idArr[i]).setOnClickListener(this);
        }

        ///ImageRotateActivity.jumpTo(this);
        LoadingWheelActivity.jumpTo(this);
    }

    public void onViewClicked(View view) {

        if (view.getId() == R.id.btn_01) {
            LoadingBox.showProgress(view.getContext());
            delayDismissProgressDialog();
        }

        if (view.getId() == R.id.btn02) {
            LoadingBox.showProgress(this, text01);
            delayDismissProgressDialog();
        }

        if (view.getId() == R.id.btn03) {
            LoadingBox.showProgress(this, "");
            delayDismissProgressDialog();
        }

        if (view.getId() == R.id.btn04) {
            LoadingConfig mDialogConfig = new LoadingConfig.Builder()
                    //点击外部是否可以取消
                    .isCanceledOnTouchOutside(true)
                    //物理返回键可以取消
                    .isCancelable(true)
                    //全屏背景窗体的颜色
                    //.setBackgroundWindowColor(UIUtils.getColor(R.color.colorDialogWindowBg))
                    //View背景的颜色
                    //.setBackgroundViewColor(UIUtils.getColor(R.color.colorDialogViewBg))
                    //View背景的圆角
                    .setCornerRadius(20)
                    //View 边框的颜色
                    //.setStrokeColor(UIUtils.getColor(R.color.colorAccent))
                    //View 边框的宽度
                    .setStrokeWidth(2)
                    //Progress 颜色
                    //.setProgressColor(UIUtils.getColor(R.color.colorDialogProgressBarColor))
                    //Progress 宽度
                    .setProgressWidth(3)
                    //Progress 内圈颜色
                    .setProgressRimColor(Color.YELLOW)
                    //Progress 内圈宽度
                    .setProgressRimWidth(4)
                    //文字的颜色
                    //.setTextColor(UIUtils.getColor(R.color.colorDialogTextColor))
                    //文字的大小
                    .setTextSize(15)
                    //ProgressBar 颜色
                    .setProgressColor(Color.GREEN)
                    //dialog动画
                    .setAnimationID(R.style.animate_dialog_custom)
                    //padding
                    .setPadding(40, 10, 40, 10)
                    //关闭的监听
                    .setOnDialogDismissListener(new OnDialogDismissListener() {
                        @Override
                        public void onDismiss() {
                            //UIUtils.toast("监听到了ProgressDialog关闭了");
                        }
                    })
                    .build();
            LoadingBox.showProgress(this, "数据上传中...", mDialogConfig);
        }

        if (view.getId() == R.id.btn06) {
            LoadingConfig mDialogConfig = new LoadingConfig.Builder()
                    //点击外部是否可以取消
                    .isCanceledOnTouchOutside(true)
                    //物理返回键可以取消
                    .isCancelable(false)
                    //View背景的颜色
                    .setBackgroundViewColor(getColor(R.color.uploadDialogViewBg))
                    //View背景的圆角
                    .setCornerRadius(8)
                    //Progress 颜色
                    //.setProgressColor(UIUtils.getColor(R.color.colorDialogProgressBarColor))
                    //Progress 宽度
                    .setProgressWidth(5)
                    //Progress 内圈颜色
                    .setProgressRimColor(Color.parseColor("#C7EEFC"))
                    //文字的颜色
                    .setTextColor(getColor(R.color.uploadDialogTextColor))
                    //文字的大小
                    .setTextSize(15)
                    //ProgressBar 颜色
                    .setProgressColor(Color.parseColor("#380EF4"))
                    //dialog动画
                    .setAnimationID(R.style.animate_dialog_custom)
                    //关闭的监听
                    .setOnDialogDismissListener(new OnDialogDismissListener() {
                        @Override
                        public void onDismiss() {
                            //UIUtils.toast("监听到了ProgressDialog关闭了");
                        }
                    })
                    .build();
            UploadLoadingBox.showProgress(this, "正在整理您的路书 请耐心等待...", mDialogConfig);
        }

    }

    private void delayDismissProgressDialog() {
        findViewById(R.id.btn_01).postDelayed(() -> LoadingBox.dismissProgress(), 3000);
    }

    @Override
    public void onClick(View v) {
        onViewClicked(v);
    }
}

